/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controladores;
import Clases.Alumno;
import Clases.Alumno;
import java.util.Date;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
/**
 *
 * @author PaBLo
 */
public class AlumnoPersonalizado extends AlumnoJpaController {
    public AlumnoPersonalizado(EntityManagerFactory emf){
        super(emf);
    }
    public List<Alumno> pBuscarPorCodigoPersonal(String cod){
       EntityManager em = super.getEntityManager();
       return em.createQuery("SELECT a FROM Alumno a WHERE a.codigoPersonal = '"+cod+"'").getResultList();
    }
    public int UltimoId(){
        EntityManager em = super.getEntityManager();
        List<Alumno> todos = em.createQuery("select a from Alumno a").getResultList();
        if(todos.isEmpty()){
            return 0;
        }else{
            Alumno ultimo = todos.get(todos.size()-1);
            return ultimo.getIdAlumno();
        }
    }
    public List<Alumno> pTodosLosAlumnos(){
        EntityManager em = super.getEntityManager();
        return em.createQuery("select a from Alumno a").getResultList();
    }
    public List<Alumno> pAlumnosHabilitados(){
        EntityManager em = super.getEntityManager();
        return em.createQuery("SELECT a FROM Alumno a WHERE a.vigente = 1").getResultList();
    }
    public List<Alumno> pAlumnosDeshabilitados(){
        EntityManager em = super.getEntityManager();
        return em.createQuery("SELECT a FROM Alumno a WHERE a.vigente = 0").getResultList();
    }
}
